<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" href="/top_gay/jquery-ui.min.css" rel="stylesheet">
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<link media="screen" rel="stylesheet" href="/${initParam.context_root }/css/bootstrap.min.css">
<script type="text/javascript" src="/top_gay/jquery-ui.min.js"></script>
<script type="text/javascript">
	if ('${requestScope.check_num }') {
		alert("전송이 완료되었습니다.");
	}

	$(document).ready(function() {

		$("#buttonMessage").on("click", function() {
			$("#messagePopup").dialog({
				width : 361,
				height : 485,
				buttons : {
					"닫기" : function() {
						$(this).dialog("close");
					},
					"전송" : function() {
						$("form").submit();
					}
				}
			});
		});

		$("#btnDeclaration").on("click", function(){
			$("#dialogDeclarationPopup").dialog({
				width:550
				, height:450
				, modal:true
				, buttons:{
					"send":function(){
						var content = $("textarea[name=contentForReply]");
						if(!content.val()){
							alert("내용을 입력하세요");
						} else {
							sendContent(this);
							content.val('');
						}
					}
					, "cancel":function(){
						$(this).dialog("close");
					}
				}
			});
		});
		
	});
	
	function sendContent(form){
		$("form[name=dialogDeclarationForm]").on("submit", function(){
			var queryString = $(this).serialize();
			alert(queryString);
			return false;
		});
		/* $.ajax({
			url:"/${initParam.context_root}/cscenter/login/writeDeclarationContent.do"
			, type:"POST"
			, data:$("form[name=dialogDeclarationForm]").serialize()
			, success:function(txt){
				alert(txt);
			}
		}); */
		$(form).dialog("close");
		
	}
</script>


<title>Profile Page</title>
</head>
<body>
	<div class="container">

		<div class="page-header">
			<h1>${sessionScope.member_info.name }님의프로필</h1>
		</div>

		<c:if test="${sessionScope.member_info != null }">
			<table class="table table-hover">
				<thead>
				</thead>

				<tbody>
					<tr>
						<td rowspan="5"><img src="/TopGay/image/icon_23638.png" alt="profile" class="img-rounded"
							width="170px"></td>
						<td>ID : ${sessionScope.member_info.id }</td>
					</tr>
					<tr>
						<td>이름 : ${sessionScope.member_info.name}</td>
					</tr>

					<tr>
						<td>생일 : ${sessionScope.member_info.birth}</td>
					</tr>
					<tr>
						<td>지역 : ${sessionScope.member_info.city}</td>
					</tr>
					<tr>
						<td>Email : ${sessionScope.member_info.email}</td>
					</tr>
				</tbody>
			</table>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">자기소개</h3>
				</div>
				<div class="panel-body">${sessionScope.member_info.selfIntroduction}</div>
			</div>
		</c:if>
		<div style="float: right">
			<!-- 신고 버튼에 대한 링크를 걸어야 함 -->
			<button id="btnDeclaration" type="button" class="btn btn-warning"><img src="/${initParam.context_root }/image/icon_2039.png" width="22px" border="0"></button>
			<button id="buttonMessage" type="button" class="btn btn-primary">쪽지 보내기</button>

			<c:if test="${param.flag == 0}">
				<button type="button" class="btn btn-danger"
					onclick="location.href='/${initParam.context_root }/friendList/deleteFriendList.do?myId=${sessionScope.login_info.id }&friendId=${sessionScope.member_info.id }'">친구
					삭제</button>
			</c:if>
			<c:if test="${param.flag == 1}">
				<button type="button" class="btn btn-info"
					onclick="location.href='/${initParam.context_root }/friendList/addFriend.do'">친구 추가</button>
			</c:if>
		</div>

		<%-- <form action="${initParam.root_path }/friendList/addFriend.do"> --%>

		<br>


		<div id="messagePopup" class="dialog" title="쪽지 보내기" style="display: none">
			<form action="/${initParam.context_root }/message/messageSend.do">
				제목<input type="text" name="title" placeholder="제목을 입력하세요" size="42" /><br> <br>
				<!-- 창 크기와 버튼을 위치를 조정하자  -->
				내용
				<textarea rows="10" cols="40" name="content" placeholder="내용을 입력하세요"></textarea>
				<input type="hidden" name="toId" value="${sessionScope.member_info.id }" /> <input
					type="hidden" name="fromId" value="${sessionScope.login_info.id }" /> <input type="hidden"
					name="friendId" value="${sessionScope.member_info.id }" /> <input type="hidden" name="myId"
					value="${sessionScope.login_info.id }" />
			</form>
		</div>
		
		<div id="dialogDeclarationPopup" class="dialog" title="신고" style="display:none;">
			<h4>우리를 욕되게 하는 자, 신고하세요!</h4>
			<form name="dialogDeclarationForm" action="/${initParam.context_root}/cscenter/login/writeDeclarationContent.do" method="post">
				<input type="hidden" name="assaulterId" value="test2">
				<textarea cols="50" rows="10" name="contentForReply"></textarea>
			</form>
		</div>
		
	</div>

</body>

</html>